package com.moleq.itemsetting.tools;

import java.io.IOException;

import com.moleq.db.DatabaseSchema;
import com.moleq.models.ItemSetting;

public class MGCreateFiles {
	ReadWriteFile mReadWriteFile = null;

	public MGCreateFiles() {
		mReadWriteFile = new ReadWriteFile();
	}

//	public void AddItemAction(ItemSetting item) {
//		try {
//			String action = writeAction("INSERT","t_item_setting",item);
//			mReadWriteFile.creatTxtFile();
////			if (mReadWriteFile.checkDBStructure() == false) {
////				mReadWriteFile.writeAddTxtFile(writeDBStructure());
////			}
//			mReadWriteFile.writeAddTxtFile(action);
//		} catch (IOException e) {
//			// TODO Auto-generated catch block 
//			e.printStackTrace();
//		}
//	}
//
//	public void DeleteItemAction(ItemSetting item) {
//		try {
//			String action = writeAction("DELETE","t_item_setting",item);
//			mReadWriteFile.creatTxtFile();
////			if (mReadWriteFile.checkDBStructure() == false) {
////				mReadWriteFile.writeAddTxtFile(writeDBStructure());
////			}
//			mReadWriteFile.writeAddTxtFile(action);
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//	}
//
//	public void ModifyItemAction(ItemSetting item) {
//		try {
//			String action = writeAction("UPDATE","t_item_setting",item);
//			mReadWriteFile.creatTxtFile();
////			if (mReadWriteFile.checkDBStructure() == false) {
////				mReadWriteFile.writeAddTxtFile(writeDBStructure());
////			}
//			mReadWriteFile.writeAddTxtFile(action);
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//	}
	
	public void createrFile(String action){
		try {
			mReadWriteFile.creatTxtFile("SET");
			mReadWriteFile.writeAddTxtFile(action);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void createrFile(String action,String type){
		try {
			if(type.equals("ITY")){
				mReadWriteFile.creatTxtFile("ITY");
			}else{
				mReadWriteFile.creatTxtFile("SET");
			}
			mReadWriteFile.writeAddTxtFile(action);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public String writeAction(String Action,String TableName,ItemSetting item) {
		String Result = Action + "|" + TableName + "|('" + item.getUpc() + "','" + item.getName()
				+ "'," + item.getDep() + "," + item.getSubDep() + ",'"
				+ item.getActive() + "'," + item.getCasePack() + ",'"
				+ item.getNetWT() + "'," + item.getWt() + ",'" + item.getVendor()
				+ "','" + item.getDesc() + "'," + item.getPrice() + ","
				+ item.getMultple() + "," + item.getCaseCost() + ",'"
				+ item.getFoodStamp() + "','" + item.getTax1() + "','"
				+ item.getScaleWeight() + "','" + item.getWic() + "','"
				+ item.getCvv() + "','" + item.getCreate_datetime() + "','"
				+ item.getUpdate_datetime() + "','" + item.getFollowdep() + "','"
				+ item.getTax2() + "','" + item.getTax3() + "','" + item.getTax4()
				+ "','" + item.getItem_discount_flag() + "','"
				+ item.getBottle_deposit() + "','" + item.getIs_loyalty() + "',"
				+ item.getIs_tare() + ",'" + item.getIs_age_ver() + "','"
				+ item.getTax5() + "','" + item.getTax6() + "','" + item.getIs_coupon() + "')";
		return Result;
	}
}
